from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from base.base import Base

class Page_Personal(Base):

    login_username_locator = (By.XPATH,'//span[@class="hidden-sm-and-down"]')
    personal_center_locator = (By.XPATH,'//div[text()="个人中心"]')
    operationrole_locator = (By.XPATH,'(//div[@class="user-info-tags"])[1]')
    datarole_locator = (By.XPATH,'(//div[@class="user-info-tags"])[2]')
    basic_information_locator = (By.CLASS_NAME,'ant-form-item-control-input-content')

    def get_login_username(self):
        return self.get_text(self.login_username_locator)
    
    def enter_personal_center(self):
        ActionChains(self.driver).move_to_element(self.find(self.login_username_locator)).perform()
        ActionChains(self.driver).click(self.find(self.personal_center_locator)).perform()

    def get_operationrole(self):
        return self.get_text(self.operationrole_locator)
    
    def get_datarole(self):
        return self.get_text(self.datarole_locator)
    
    def get_basic_information(self):
        values = []
        informations = self.finds(self.basic_information_locator)
        for index,elm in enumerate(informations):
            values.append(elm.text)
        return values


